import lazy from "@/components/directives/lazy";
import Message from "./Message";

// 1.获取模块的路径集合 获取模块的导入函数
const inputFn = require.context("./", false, /\.vue$/);
// 2.获取要导入的文件的路径数组
const keys = inputFn.keys();
console.log(keys);

export default {
  install(app) {
    app.directive("lazy", lazy);
    // 将message方法添加到全局属性中
    app.config.globalProperties.$message = Message;
    // 遍历要导入的文件的路径
    keys.forEach((item) => {
      // 动态导入组件
      const components = inputFn(item).default;
      // 注册组件
      app.component(components.name, components);
    });
  },
};

// import XtxSkeleton from "@/components/library/XtxSkeleton";
// import XtxCarousel from "@/components/library/XtxCarousel";
// import XtxMore from "@/components/library/XtxMore";
// import lazy from "@/components/directives/lazy";
// import XtxBreadItem from "@/components/library/XtxBreadItem";
// import XtxBread from "@/components/library/XtxBread";
//
//
// export default {
//   install(app) {
//     app.components(XtxSkeleton.name, XtxSkeleton);
//     app.components(XtxCarousel.name, XtxCarousel);
//     app.components(XtxMore.name, XtxMore);
//     app.components(XtxBreadItem.name, XtxBreadItem);
//     app.components(XtxBread.name, XtxBread);
//     app.directive("lazy", lazy);
//   },
// };
